<?php

class SystemAction extends CommonAction {
    
	// 公共配置
	public function common(){
		$this->assign('client_currency',explode(',',$this->rs['client_currency']));
		$this->assign('factory_currency',explode(',',$this->rs['factory_currency']));
		$this->assign('logistics_currency',explode(',',$this->rs['logistics_currency']));
		$this->assign('company_currency',explode(',',$this->rs['company_currency']));
		$this->display();
	}
	
	// 更新各流程库存规格与固定配置一致
	 public function updateFlowStorage(){
    	$flow = array('order','loadContainer','instock','sale','preDelivery','delivery','adjust','transfer','stocktake','initStorage');
    	$key = array('color','size','storage_format','mantissa');
    	$flow_to_once = array('color'=>'storage_color','size'=>'storage_size','storage_format'=>'storage_format','mantissa'=>'storage_mantissa');
    	foreach ($flow as $type) {
    		foreach ($key as $value) {M('Config')->where('`key`=\''.$value.'\' and `type`=\''.$type.'\'')->delete();
    			if ($type=='order' && $value=='mantissa') {
    				continue;
    			}
    			
    			$value2 = C($flow_to_once[$value]);
    			if (empty($value2)) {$value2 = 2;}
    			M('Config')->add(array('key'=>$value,'value'=>$value2,'type'=>$type,'type_key'=>1));
    		}
    	}
    	D('Admin')->updateCofig();
    	redirect('once',2,'保存成功，2秒后跳转');
    }
}